package com.larry.rabbitmq.util;

import com.rabbitmq.client.*;


/**
 * @author larry
 * @Title: larry-rabbitmq
 * @Package com.larry.rabbitmq.util
 * @Description: 工具类 获取信道
 * 默认用户 guest guest
 * @date 6/28/216:31 PM
 */
public class RabbitMQUtils {

    //得到一个连接的channel
    public static Channel getChannel() throws Exception{
        //创建一个连接工厂
        ConnectionFactory factory = new ConnectionFactory();
        //工厂ip 连接rabbitmq的队列
//        factory.setHost("10.211.55.3");
        factory.setHost("47.93.55.0");
        //用户名
        factory.setUsername("guest");
        //密码
        factory.setPassword("guest");

        //创建连接
        Connection connection = factory.newConnection();
        //获取信道
        Channel channel = connection.createChannel();

        return channel;
    }
}
